﻿#region Imports
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using CommonUtilities.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
#endregion

namespace CommonUtilities.UnitTest.UTExtensions
{
    [TestClass]
    public class MiscExtensions_Test
    {
        #region Test methods
        [TestMethod]
        public void AutoGenerateColumns_Test()
        {
            // EXPECTED
            ObservableCollection<string> expected = new ObservableCollection<string>();

            // ACTUAL
            DataGridView actual = new DataGridView();
            actual.GenerateDGVColumns<Test_Entity>(true);

            // RESULT

        }

        /// <summary>
        /// A test for FormatXmlTags
        /// </summary>
        [TestMethod]
        public void FormatXmlTags_Test()
        {
            // EXPECTED
            Dictionary<string, string> dictExpectedActualMapping = new Dictionary<string, string>();

            dictExpectedActualMapping.AddToDictionary("&", "&amp;");
            dictExpectedActualMapping.AddToDictionary("<", "&lt;");
            dictExpectedActualMapping.AddToDictionary(">", "&gt;");
            dictExpectedActualMapping.AddToDictionary("'", "&apos;");
            dictExpectedActualMapping.AddToDictionary("\"", "&quot;");

            // ACTUAL
            bool isRestoreOp = false; // TODO: Initialize to an appropriate value
            bool actualConversion = dictExpectedActualMapping._All(act => act.Value == MiscExtensions.FormatXmlTags(act.Key, isRestoreOp));

            isRestoreOp = true; // TODO: Initialize to an appropriate value
            bool actualRestore = dictExpectedActualMapping._All(act => act.Key == MiscExtensions.FormatXmlTags(act.Value, isRestoreOp));

            // RESULT
            Assert.AreEqual(actualConversion, true);
            Assert.AreEqual(actualRestore, true);
        }

        /// <summary>
        /// A test for AppendPath
        /// </summary>
        [TestMethod]
        public void AppendPath_Test()
        {
            // EXPECTED
            string expected = @"C:\a\b\c";

            // ACTUAL
            string basep1 = @"C:\";
            string[] paths1 = { "a:\\\\", "b\\", "c" };

            string basep2 = @"C";
            string[] paths2 = { "a:\\\\", "b\\", "c" };

            string basep3 = @"C";
            string[] paths3 = { "a:\\\\", "b:\\", "c" };

            // RESULT
            Assert.AreEqual(expected, basep1.AppendPath(paths1));
            Assert.AreEqual(expected, basep2.AppendPath(paths2));
            Assert.AreEqual(expected, basep3.AppendPath(paths3));
            Assert.AreEqual("", "".AppendPath(new string[] { "", "", "" }));
        }
        #endregion
    }
}
